package com.example.administrator.x3picturetransliteration.Util;

import android.content.Context;
import android.content.SharedPreferences;

public class SpUtils {
    private static SpUtils utils;
    public static SpUtils getInstance(){
        if(null==utils){
            synchronized (SpUtils.class){
                utils=new SpUtils();
            }
        }
        return utils;
    }

    private SharedPreferences sp;
    private SharedPreferences.Editor editor;

    private void initSp(Context context){
        if(null==sp){
            sp= context.getSharedPreferences("protocol_sp",Context.MODE_PRIVATE);
        }
        if(null==editor){
            editor=sp.edit();
        }
    }
    public void agree(Context context,boolean agree){
        initSp(context);
        editor.putBoolean("agree",agree);
        editor.commit();
    }

    public boolean getAgree(Context context){
        initSp(context);
        return sp.getBoolean("agree",false);
    }
}
